package com.laiyizhan.cms.first.controller;

import com.laiyizhan.cms.first.request.LastFourRequest;
import com.laiyizhan.cms.first.service.ILastFourService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

/**
 * Created by SoulWolf on 2017/7/22.
 */
@Controller
@RequestMapping("/admin")
public class LastFourController {
    @Autowired
    ILastFourService iLastFourService;

    /*目录页面*/
    @RequestMapping(value = "/eighth/index/show")
    public String Eighth_index(LastFourRequest request,HttpSession httpSession,ModelMap modelMap) {
        request.setoName((String)httpSession.getAttribute("oName"));
        httpSession.setAttribute("number", 1);
        modelMap.put("state",iLastFourService.LastFour_index(request));
        return "/eighth/index";
    }



    @RequestMapping(value = "/eighth/a/show")
    public String eighth_a(LastFourRequest request) {
        return "/eighth/main";
    }
    @RequestMapping(value = "/eighth/a")
    public String Eighth_a_record( LastFourRequest request, HttpSession httpSession,ModelMap modelMap) {
        request.setoName((String)httpSession.getAttribute("oName"));
        String result = iLastFourService.Eighth_a(request);
        modelMap.put("state",iLastFourService.LastFour_index(request));
        if(result=="no"){
            modelMap.put("error","当职称人数不为0的时候，该职称的在职工年人均工资也不能为0");
            modelMap.put("link","/admin/eighth/a/show");
            return "/error/error";
        }
        return "/eighth/index";
    }

    @RequestMapping(value = "/eighth/b/show")
    public String eighth_b(LastFourRequest request) {
        return "/eighth/b";
    }
    @RequestMapping(value = "/eighth/b")
    public String Eighth_b_record(LastFourRequest request,HttpSession httpSession,ModelMap modelMap) {
        request.setoName((String)httpSession.getAttribute("oName"));
        iLastFourService.Eighth_b(request);
        modelMap.put("state",iLastFourService.LastFour_index(request));
        return "/eighth/index";
    }

    @RequestMapping(value = "/eighth/c/show")
    public String eighth_c(LastFourRequest request) {
        return "/eighth/c";
    }
    @RequestMapping(value = "/eighth/c")
    public String Eighth_c_record( LastFourRequest request,HttpSession httpSession,ModelMap modelMap) {
        request.setoName((String)httpSession.getAttribute("oName"));
        iLastFourService.Eighth_c(request);
        modelMap.put("state",iLastFourService.LastFour_index(request));
        return "/eighth/index";
    }

/*
*
* 以下为第九类
*
* */
    /*目录页面*/
    @RequestMapping(value = "/ninth/index/show")
    public String Ninth_index(LastFourRequest request,HttpSession httpSession,ModelMap modelMap) {
        request.setoName((String)httpSession.getAttribute("oName"));
        httpSession.setAttribute("number", 1);
        modelMap.put("state",iLastFourService.LastFour_index(request));
        return "/ninth/index";
    }


    @RequestMapping(value = "/ninth/a/show")
    public String ninth_a(LastFourRequest request) {
        return "/ninth/main";
    }
    @RequestMapping(value = "/ninth/a")
    public String Ninth_a_record(LastFourRequest request,HttpSession httpSession,ModelMap modelMap) {
        request.setoName((String)httpSession.getAttribute("oName"));
        String result = iLastFourService.Ninth_a(request);
        modelMap.put("state",iLastFourService.LastFour_index(request));
        if(result=="no"){
            modelMap.put("error","当职称人数不为0的时候，该职称的在职工年人均工资也不能为0");
            modelMap.put("link","/admin/ninth/a/show");
            return "/error/error";
        }
        return "/ninth/index";
    }

    @RequestMapping(value = "/ninth/b/show")
    public String Ninth_b() {
        return "/ninth/b";
    }
    @RequestMapping(value = "/ninth/b")
    public String Ninth_b_record(LastFourRequest request,HttpSession httpSession,ModelMap modelMap) {
        request.setoName((String)httpSession.getAttribute("oName"));
        iLastFourService.Ninth_b(request);
        modelMap.put("state",iLastFourService.LastFour_index(request));
        return "/ninth/index";
    }

    @RequestMapping(value = "/ninth/c/show")
    public String Ninth_c() {
        return "/ninth/c";
    }

    @RequestMapping(value = "/ninth/c")
    public String Ninth_c_record(LastFourRequest request,HttpSession httpSession,ModelMap modelMap) {
        request.setoName((String)httpSession.getAttribute("oName"));
        iLastFourService.Ninth_c(request);
        modelMap.put("state",iLastFourService.LastFour_index(request));
        int order = (int)httpSession.getAttribute("number");
        if(request.getNumber()<5){
            httpSession.setAttribute("number",order+1);
        }else{
            return "ninth/index";
        }
        return "/ninth/c";
    }
/*
*
* 以下为第十类
*
* */

    /*目录页面*/
    @RequestMapping(value = "/tenth/index/show")
    public String Tenth_index(LastFourRequest request,HttpSession httpSession,ModelMap modelMap) {
        request.setoName((String)httpSession.getAttribute("oName"));
        httpSession.setAttribute("number", 1);
        modelMap.put("state",iLastFourService.LastFour_index(request));
        return "/tenth/index";
    }


    @RequestMapping(value = "/tenth/a/show")
    public String tenth_a(LastFourRequest request) {
        return "/tenth/main";
    }
    @RequestMapping(value = "/tenth/a")
    public String Tenth_a_record(LastFourRequest request,HttpSession httpSession,ModelMap modelMap) {
        request.setoName((String)httpSession.getAttribute("oName"));
        String result = iLastFourService.Tenth_a(request);
        modelMap.put("state",iLastFourService.LastFour_index(request));
        if(result=="no"){
            modelMap.put("error","当职称人数不为0的时候，该职称的在职工年人均工资也不能为0");
            modelMap.put("link","/admin/tenth/a/show");
            return "/error/error";
        }
        return "/tenth/index";
    }

    @RequestMapping(value = "/tenth/b/show")
    public String Tenth_b() {
        return "/tenth/b";
    }
    @RequestMapping(value = "/tenth/b")
    public String Tenth_b_record(LastFourRequest request,HttpSession httpSession,ModelMap modelMap) {
        request.setoName((String)httpSession.getAttribute("oName"));
        iLastFourService.Tenth_b(request);
        modelMap.put("state",iLastFourService.LastFour_index(request));
        return "/tenth/index";
    }


    @RequestMapping(value = "/tenth/c/show")
    public String Tenth_c() {
        return "/tenth/c";
    }
    @RequestMapping(value = "/tenth/c")
    public String Tenth_c_record(LastFourRequest request,HttpSession httpSession,ModelMap modelMap) {
        request.setoName((String)httpSession.getAttribute("oName"));
        iLastFourService.Tenth_c(request);
        modelMap.put("state",iLastFourService.LastFour_index(request));
        return "/tenth/index";
    }



    /*以下为第十一类*/


    /*目录页面*/
    @RequestMapping(value = "/eleventh/index/show")
    public String Eleventh_index(LastFourRequest request,HttpSession httpSession,ModelMap modelMap) {
        request.setoName((String)httpSession.getAttribute("oName"));
        httpSession.setAttribute("number", 1);
        modelMap.put("state",iLastFourService.LastFour_index(request));
        return "/eleventh/index";
    }


    @RequestMapping(value = "/eleventh/a/show")
    public String eleventh_a(LastFourRequest request) {
        return "/eleventh/main";
    }
    @RequestMapping(value = "/eleventh/a")
    public String eleventh_a_record(LastFourRequest request,HttpSession httpSession,ModelMap modelMap) {
        request.setoName((String)httpSession.getAttribute("oName"));
        iLastFourService.Eleventh_a(request);
        modelMap.put("state",iLastFourService.LastFour_index(request));
        return "/eleventh/index";
    }




}
